<?php

namespace RegisterUser\Model;

class DAL {
	
	private $connection;
	
	function __construct(){
		//$this -> connection = mysqli_connect('mysql.hostinger.se', 'u224483982_ep222', '3.2databas', 'u224483982_ep222');
		$this -> connection = mysqli_connect('127.0.0.1', 'root', '', 'userdatabase');
	}
	
	function test (){
		$userArray = array();
		$result = mysqli_query($this -> connection, "SELECT * FROM user");
		while($row = mysqli_fetch_array($result)){
			$userArray[] = $row;
		}
		return $userArray;
	}
	
	/**
	 * @return Array
	 */
	public function getUserArray(){
		$userArray = array();
		$result = mysqli_query($this -> connection, "SELECT * FROM user");
		while($row = mysqli_fetch_array($result)){
			$userArray[] = $row;
		}
		return $userArray;
	}
	
	public function insertUser($newUser, $newPass){
		mysqli_query($this -> connection, "INSERT INTO `user`(`Username`, `Password`) VALUES ('$newUser','$newPass')");
	}
}
